package com.project.communitymanagement.common;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * @ProjectName: hotelNew
 * @Package: com.setup.mysql.common
 * @ClassName: BaseController
 * @Author: "XGP"
 * @Description:
 * @Date: 2021/09/13 11:28
 * @Version: 1.0
 */
public abstract class BaseController<IService extends BaseService,Model> {
    protected abstract IService service();
    @PostMapping(UrlConstant.Route.ROUTE_ADD)
    public ResponseEntity add(@RequestBody Request<Model> data){
        return ResponseEntity.success(service().save(data.getData()));
    }
    @PostMapping(UrlConstant.Route.ROUTE_EDIT)
    public ResponseEntity edit(@RequestBody Request<Model> data){
        return ResponseEntity.success(service().edit(data.getData()));
    }
    @PostMapping(UrlConstant.Route.ROUTE_DEL)
    public ResponseEntity del(@RequestBody Request<Integer> data){
        return ResponseEntity.success(service().del(data.getData()));
    }
    @PostMapping(UrlConstant.Route.ROUTE_LIST)
    public ResponseEntity<Page> list(@RequestBody Page<Model> data){
        return ResponseEntity.success(service().getPages(data));
    }
}

